package com.jt.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Date;

@Component//将该类交给容器管理
public class MyMetaObjectHandler implements MetaObjectHandler{
    @Override
    public void insertFill (MetaObject metaObject){
        Date date=new Date();
        this.setFieldValByName("created",date,metaObject);
        this.setFieldValByName("updated",date,metaObject);
    }
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updated",new Date(),metaObject);//?set怎么来的,set是接口中方法,接口的导包
    }


}
